package io.github.junxworks.qt.modules.data.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import io.github.junxworks.ep.core.orm.BaseMapper;
import io.github.junxworks.qt.config.ds.Sharding;
import io.github.junxworks.qt.modules.tushare.entity.DStockTradeDaily;

/**
 * @program :springbootdev
 * @description:
 * @author:Junxworks
 * @create:2019-08-17 15:03
 */
@Sharding
public interface HistoryMapper extends BaseMapper {

	/**
	 * 获取第index个交易日前的日期
	 *
	 * @param size the size
	 * @return the trans date
	 */
	String getTransDate(@Param("range") int range);

	/**
	 * 获取某个日期之前的N个交易日，不算date当日
	 *
	 * @param date yyyyMMdd,如20210101
	 * @param index the index
	 * @return the trans date before
	 */
	String getTransDateBefore(@Param("date") String date, @Param("range") int range);

	/**
	 * 根据股票和交易日取历史信息
	 *
	 * @param stockCode the stock code
	 * @param tradeDate the trade date
	 * @return the history by code and date
	 */
	DStockTradeDaily getTradeDataByCodeAndDate(@Param("stockCode") String stockCode, @Param("tradeDate") String tradeDate);

	List<DStockTradeDaily> queryTradeDataByCodeAndDateRange(@Param("stockCode") String stockCode, @Param("startDate") String startDate, @Param("endDate") String endDate);
}
